package com.zhenlong01.zhentest.util;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @author Administrator
 * @date 2019-08-26 14:30
 */
@Component
public class FindAccessTokenTask {
    @Resource
    RedisTemplate<String,Object> redisTemplate;
    @Scheduled(fixedRate = 1000*60*60*2)
    public void find(){
        String accessToken = (String) redisTemplate.opsForValue().get("access_token");
        if(accessToken==null) {
            try {
                AccessTokenUtil.findAccessToken(redisTemplate);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
}
